Skip to content

Disable log scale for negative or non-unique values for Histograms#13496

Open
eilskra wants to merge 1 commit intoequinor:mainfrom
eilskra:log-scale-fix
Open

Disable log scale for negative or non-unique values for Histograms#13496
eilskra wants to merge 1 commit intoequinor:mainfrom
eilskra:log-scale-fix

Conversation

@eilskra
Copy link
Copy Markdown
Contributor

@eilskra eilskra commented May 6, 2026

Issue
Resolves #12527

Approach
Set log scale button visibility to False for non-unique values, as the type checking of
distribution == "CONST" does not catch non-unique values (e.g single realization runs).

Removed +- 0.5 in _plotHistogram(), as this is condition will never be met since min == max and transformation already completed previously in plotHistogram()

  • PR title captures the intent of the changes, and is fitting for release notes.
  • Added appropriate release note label
  • Commit history is consistent and clean, in line with the contribution guidelines.
  • Make sure unit tests pass locally after every commit (git rebase -i main --exec 'just rapid-tests')

When applicable

  • When there are user facing changes: Updated documentation
  • New behavior or changes to existing untested code: Ensured that unit tests are added (See Ground Rules).
  • Large PR: Prepare changes in small commits for more convenient review
  • Bug fix: Add regression test for the bug
  • Bug fix: Add backport label to latest release (format: 'backport release-branch-name')

@eilskra eilskra added the release-notes:bug-fix Automatically categorise as bug fix in release notes label May 6, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.96%. Comparing base (b4ed493) to head (372d947).
⚠️ Report is 7 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13496      +/-   ##
==========================================
+ Coverage   89.90%   89.96%   +0.05%     
==========================================
  Files         460      460              
  Lines       32372    32406      +34     
==========================================
+ Hits        29105    29153      +48     
+ Misses       3267     3253      -14     
Flag Coverage Δ
cli-tests 37.05% <0.00%> (-0.13%) ⬇️
fuzz 44.03% <0.00%> (-0.02%) ⬇️
gui-tests 66.59% <80.00%> (-0.25%) ⬇️
performance-and-unit-tests 77.97% <100.00%> (+0.02%) ⬆️
test 45.69% <0.00%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/ert/gui/tools/plot/plot_widget.py 97.46% <100.00%> (ø)
src/ert/gui/tools/plot/plot_window.py 86.51% <100.00%> (ø)
src/ert/gui/tools/plot/plottery/plots/histogram.py 96.46% <ø> (+1.63%) ⬆️

... and 13 files with indirect coverage changes

@andreas-el
Copy link
Copy Markdown
Contributor

andreas-el commented May 7, 2026

Needs a backport to version-21.1
and to
version-22.0

Comment thread src/ert/gui/tools/plot/plot_window.py Outdated
@eilskra eilskra force-pushed the log-scale-fix branch 5 times, most recently from e8e6b05 to ed65c06 Compare May 7, 2026 11:54
Comment thread tests/ert/unit_tests/gui/tools/plot/test_plot_window.py Outdated
Comment thread src/ert/gui/tools/plot/plottery/plots/histogram.py
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 7, 2026

Merging this PR will not alter performance

✅ 36 untouched benchmarks


Comparing eilskra:log-scale-fix (372d947) with main (15b1b96)

Open in CodSpeed

Comment thread src/ert/gui/tools/plot/plottery/plots/histogram.py
Comment thread src/ert/gui/tools/plot/plot_window.py Outdated
@berland

This comment was marked as resolved.

@eilskra eilskra force-pushed the log-scale-fix branch 3 times, most recently from 8b85b09 to 1e32a39 Compare May 8, 2026 11:01
@eilskra eilskra changed the title Disable log scale when value is within 0.1 of zero for Histograms Disable log scale when for negative or non-unique values for Histograms May 8, 2026
@eilskra eilskra force-pushed the log-scale-fix branch 3 times, most recently from 3786c20 to 29da8f8 Compare May 8, 2026 11:59
@eilskra eilskra self-assigned this May 8, 2026
@berland
Copy link
Copy Markdown
Contributor

berland commented May 8, 2026

The "when for" in the commit title does not really make sense, can you reword?

@eilskra eilskra changed the title Disable log scale when for negative or non-unique values for Histograms Disable log scale for negative or non-unique values for Histograms May 8, 2026
Prevent log scale button for non-unique values, type checking of
distribution == "CONST" does not catch all.
# distribution is not set as CONSTANT
if not numeric.empty and (
numeric.le(0).any().any() or numeric.nunique().le(1).all()
):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to disable log_scale for single realization runs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not equivalent of a constant distribution?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would look the same as a constant distribution with the same min/max, but i dont think it would be the same. I guess it wouldnt be of much value to log_scale a single value, but it is something be currently support..

ensemble_to_data_map[ensemble] = result

negative_values_in_data = False
negative_or_non_unique_values_in_data = False
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change this to negative_values_in_data_or_all_same_value? I think it reads a bit better. Alternatively, should we have this as two different flags (or maybe even three - empty_data as well)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport version-21.1 backport version-22.0 release-notes:bug-fix Automatically categorise as bug fix in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug in histogram plotter

7 participants